L=8 ; K = 5
lambda = function(t) { 100 + 50/exp((t - 420)^2/(3600*L)) + 100/exp((L*(t - 480 - 30*L)^2)/360000)}

eventsPerMinute = 800                 # pocet pokusu behem minuty
eventsLength =  24 * 60 * (eventsPerMinute)
eventsInMinute = numeric(24 * 60)
events = numeric(eventsLength)      # zaznam vsech pokusu 
rand = runif(eventsLength, min=0, max=1)   # Nahodna hodnota  

for(i in 1:1:eventsLength){
    time = floor((i-1)/eventsPerMinute)+1  # aktualni minuta
    
    if (rand[i] < lambda(time) * (1/eventsPerMinute)) {
        events[i]=1;
        eventsInMinute[time] = eventsInMinute[time] + 1
    } 
}
# prvnich 50 prichodu na server
plot(x=which(events==1)[1:(K*10)]/eventsPerMinute, y=numeric(K*10),xlab="Čas v minutách",ylab="")
# prichody na server behem celeho dne
t = 1:1:(24*60)
plot(x=t,y=eventsInMinute,lwd=1, type='l',xlab="Čas v minutách",ylab="Příchody za minutu")
lines (x=t,lambda(t), lwd=4, col='red')